/**
 * Created by mapbar_front on 2019/8/2.
 */
import React,{Component} from 'react';

function Hoc1(WrappedComponent){
    return class Hoc111 extends Component{
        constructor(props){
            super(props);
            this.state = {
                value: '',
            }
        }
        refc(instance){
            //instance.getName && alert(instance.getName());
        }
        onChange=(e)=>{
            this.setState({
                value: e.target.value,
            })
        }
        render(){
            const {age,...otherProps} = this.props;
            const newProps = {
                value: this.state.value,
                onChange: this.onChange,
            }
            return(
                <div>
                    <h1>这是一个高阶组件</h1>
                    <WrappedComponent sex="男"
                                      {...otherProps}
                                      ref={this.refc.bind(this)}
                                      {...newProps}
                    />
                </div>
            )
        }
    }
}
export default Hoc1;

